﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;
using System.Collections;//Please add references

namespace Hyfw.DAL
{
  public   class CommonService
    {
        /// <summary>
        /// 执行分页存储过程
        /// </summary>
        /// <param name="key">搜索关键字</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="pageSize">页显示数量</param>
        /// <param name="sortFiled">排序字段</param>
        /// <param name="sortOrder">排序规则，降序，还是升序</param>
        /// <param name="prodceureName">存储过程名称</param>
        /// <returns>hashtable data=数据 total=总记录数</returns>
        public Hashtable Serach(string key, int pageIndex, int pageSize, string sortFiled, string sortOrder,string prodceureName)
        {
            int returnValue = 0;
            Hashtable ht = new Hashtable();
            ArrayList list = new ArrayList();
            SqlParameter[] pars ={
                    new SqlParameter("@key",key),
                    new SqlParameter("@pageIndex",pageIndex),
                    new SqlParameter("@pageSize",pageSize),
                    new SqlParameter("@sortFiled",sortFiled),
                    new SqlParameter("@sortOrder",sortOrder)
                                  };

            list = DbHelperSQL.RunProcedureJ(prodceureName, pars, "ds", out returnValue);
            ht["data"] = list;
            ht["total"] = returnValue;
            return ht;
        }
        public ArrayList GeListByProcedureName(string procedureName)
        {
            ArrayList list = new ArrayList();

            list = DbHelperSQL.RunProcedureJ(procedureName);
            
            return list;

        }
        public ArrayList GeListByProcedureName(string procedureName, SqlParameter[] param)
        {
            ArrayList list = new ArrayList();

            list = DbHelperSQL.RunProcedureJ(procedureName,param);
            
            return list;

        }
      
    }
}
